package com.ysqcould.allocation.service.impl;

import com.ysqcould.allocation.domain.WxRole;
import com.ysqcould.allocation.mapper.WxRoleMapper;
import com.ysqcould.allocation.service.IWxRoleService;
import com.ysqcould.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 角色Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-06-29
 */
@Service
public class WxRoleServiceImpl implements IWxRoleService 
{
    @Autowired
    private WxRoleMapper wxRoleMapper;

    /**
     * 查询角色
     * 
     * @param id 角色主键
     * @return 角色
     */
    @Override
    public WxRole selectWxRoleById(Long id)
    {
        return wxRoleMapper.selectWxRoleById(id);
    }

    /**
     * 查询角色列表
     * 
     * @param wxRole 角色
     * @return 角色
     */
    @Override
    public List<WxRole> selectWxRoleList(WxRole wxRole)
    {
        return wxRoleMapper.selectWxRoleList(wxRole);
    }

    /**
     * 新增角色
     * 
     * @param wxRole 角色
     * @return 结果
     */
    @Override
    public int insertWxRole(WxRole wxRole)
    {
        wxRole.setCreateTime(DateUtils.getNowDate());
        return wxRoleMapper.insertWxRole(wxRole);
    }

    /**
     * 修改角色
     * 
     * @param wxRole 角色
     * @return 结果
     */
    @Override
    public int updateWxRole(WxRole wxRole)
    {
        wxRole.setUpdateTime(DateUtils.getNowDate());
        return wxRoleMapper.updateWxRole(wxRole);
    }

    /**
     * 批量删除角色
     * 
     * @param ids 需要删除的角色主键
     * @return 结果
     */
    @Override
    public int deleteWxRoleByIds(Long[] ids)
    {
        return wxRoleMapper.deleteWxRoleByIds(ids);
    }

    /**
     * 删除角色信息
     * 
     * @param id 角色主键
     * @return 结果
     */
    @Override
    public int deleteWxRoleById(Long id)
    {
        return wxRoleMapper.deleteWxRoleById(id);
    }

    @Override
    public int updateStatus(WxRole role) {
        WxRole wxRole = wxRoleMapper.selectWxRoleById(role.getId());
        wxRole.setStatus(role.getStatus());
        return wxRoleMapper.updateWxRole(wxRole);
    }

    @Override
    public int changeIsDefaultStatus(WxRole role) {
        WxRole wxRole = wxRoleMapper.selectWxRoleById(role.getId());
        wxRole.setIsDefault(role.getIsDefault());
        return wxRoleMapper.updateWxRole(wxRole);
    }

    @Override
    public int changeStatementStatus(WxRole role) {
        WxRole wxRole = wxRoleMapper.selectWxRoleById(role.getId());
        wxRole.setStatement(role.getStatement());
        return wxRoleMapper.updateWxRole(wxRole);
    }

    @Override
    public int changeContactsStatus(WxRole role) {
        WxRole wxRole = wxRoleMapper.selectWxRoleById(role.getId());
        wxRole.setContacts(role.getContacts());
        return wxRoleMapper.updateWxRole(wxRole);
    }

    @Override
    public int changeTypeStatus(WxRole role) {
        WxRole wxRole = wxRoleMapper.selectWxRoleById(role.getId());
        wxRole.setType(role.getType());
        return wxRoleMapper.updateWxRole(wxRole);
    }
}
